import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';
import 'package:yw_bapp/pages/withdraw_detail.dart';
import 'package:yw_bapp/utils/common_class.dart';
import 'package:yw_bapp/utils/timeHandle.dart';
import 'package:yw_bapp/widgets/input_widget.dart';

class DetailItemContainer extends StatefulWidget {
  final detailObject detailItem;
  final List tagList;
  final double width;
  final double height;
  final int type;
  const DetailItemContainer(
      {Key key,
      this.width = 345,
      this.height = 222,
      this.tagList,
      this.detailItem,
      this.type = 1})
      : super(key: key);

  @override
  _DetailItemContainerState createState() => _DetailItemContainerState();
}

class _DetailItemContainerState extends State<DetailItemContainer> {
  List<detail> newList;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    handleData(context);
  }

  @override
  Widget build(BuildContext context) {
    // ignore: unrelated_type_equality_checks
    return Container(
      width: widget.width,
      height: widget.height,
      margin: EdgeInsets.only(top: 28),
      padding: EdgeInsets.all(16),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(9.0)),
      child: widget.type != 1
          ? Column(
              children: [
                Itmes(widget.tagList[0], widget.detailItem.beanNum/100),
                Itmes(widget.tagList[1], double.parse(widget.detailItem.rate)/100),
                Itmes(widget.tagList[2], '${ double.parse(widget.detailItem.serviceRate) /100}%'),
                Itmes(widget.tagList[3], widget.detailItem.orderNum),
                Itmes(
                  widget.tagList[4],
                  DateUtils.instance
                      .GLDataExchange(widget.detailItem.orderTime,
                          format: 'yyy/MM/dd  HH:mm:ss')
                      .toString(),
                ),
              ],
            )
          : Column(
              children: [
                Itmes(widget.tagList[0], widget.detailItem.curStatus),
                Itmes(
                  widget.tagList[1],
                  DateUtils.instance
                      .GLDataExchange(widget.detailItem.orderTime,
                          format: 'yyy/MM/dd  HH:mm:ss')
                      .toString(),
                ),
                Itmes(widget.tagList[2], widget.detailItem.orderNum/100),
                Itmes(widget.tagList[3], '${widget.detailItem.disOrderNum/10 == 10 ? '无折扣' : widget.detailItem.disOrderNum/10}'),
                Itmes(widget.tagList[4], widget.detailItem.orderId),
              ],
            ),
    );
  }

  //每一项的返回
  Widget Itmes(item, value) {
    return Container(
      margin: EdgeInsets.only(bottom: 16),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            "$item",
            style: TextStyle(color: ColorUtil.color("#999999"), fontSize: 15),
          ),
          Text(
            "$value",
            style: TextStyle(color: Colors.black),
          )
        ],
      ),
    );
  }

// 把数据处理成我们想要的格式
  void handleData(BuildContext context) {
  }
}

// 详情的每一项类
class detail {
  String tagName;
  String tagValue;
  detail(this.tagName, this.tagValue);
}
